﻿<local:BaseLab x:Class="Rxx.Labs.Reactive.Networking.WebClientLab"
							 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
							 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
							 xmlns:local="clr-namespace:Rxx.Labs"
							 xmlns:labs="clr-namespace:DaveSexton.Labs;assembly=DaveSexton.Labs"
							 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
							 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
							 mc:Ignorable="d"
							 d:DesignHeight="300" d:DesignWidth="400"
							 DataContext="{Binding RelativeSource={RelativeSource Self}}">

	<labs:OutOfBrowserContentControl>

		<StackPanel VerticalAlignment="Center" Margin="10">

			<ContentControl VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
											IsEnabled="{Binding IsDownloading, Converter={StaticResource InverseBooleanConverter}}">

				<Grid>
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" />
						<ColumnDefinition />
						<ColumnDefinition Width="Auto" />
					</Grid.ColumnDefinitions>

					<TextBlock Grid.Column="0" VerticalAlignment="Center"
										 Text="Media:" />

					<TextBox Grid.Column="1" VerticalAlignment="Center"
									 Text="{Binding Url, ValidatesOnExceptions=True, Mode=TwoWay}" />

					<Button Grid.Column="2" VerticalAlignment="Center"
									Margin="10,0" Padding="7"
									Content="Download"
									Click="Download" />

				</Grid>

			</ContentControl>

			<Grid Margin="10,20,10,0"
						Visibility="{Binding IsDownloading, Converter={StaticResource BooleanToVisibilityConverter}}">

				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition />
				</Grid.RowDefinitions>

				<Grid.ColumnDefinitions>
					<ColumnDefinition />
					<ColumnDefinition Width="Auto" />
				</Grid.ColumnDefinitions>

				<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal">
					<!-- WP7 does not support bindings in Run elements -->
					<TextBlock Text="Received " />
					<TextBlock Text="{Binding BytesReceived}" />
					<TextBlock Text=" of " />
					<TextBlock Text="{Binding TotalBytesToReceive}" />
					<TextBlock Text=" byte(s)" />
				</StackPanel>

				<ProgressBar Grid.Row="1" Grid.Column="0" Height="20" 
										 Minimum="0" Maximum="100"
										 SmallChange="1" LargeChange="10"
										 IsIndeterminate="{Binding IsProgressUnknown}"
										 Value="{Binding ProgressValue}" />

				<Button Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"
								Margin="10,0" Padding="7"
								Content="Cancel"
								Click="Cancel" />

			</Grid>

			<MediaElement x:Name="mediaElement" HorizontalAlignment="Center"
										Margin="0,15,0,0" MaxWidth="150" MaxHeight="150" />

		</StackPanel>

	</labs:OutOfBrowserContentControl>

</local:BaseLab>